﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Yuebon.Commons.Helpers;
using Yuebon.Commons.Models;
using Yuebon.Security.Application;
using Yuebon.Security.IServices;
using Yuebon.Security.Models;
using Yuebon.WebApp.Controllers;

namespace Yuebon.WebApp.Areas.Security.Controllers
{
    [Area("Security")]
    [Route("Security/[controller]/[action]")]
    public class RoleDataController : BusinessController<RoleData, IRoleDataService>
    {
        public RoleDataController(IRoleDataService _iService) : base(_iService)
        {
            iService = _iService;
        }

        protected override void OnBeforeInsert(RoleData info)
        {
            //留给子类对参数对象进行修改
            info.Id = GuidUtils.CreateNo();
        }

       

        /// <summary>
        /// 角色分配权限树
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public IActionResult GetPermissionTree(string roleId)
        {
            RoleDataApp roleAuthorizeApp = new RoleDataApp();
            return ToJsonContent(roleAuthorizeApp.OrganizeTreeViewJson(roleId));
        }
    }
}